﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ScoutOffice.BLL;
using System.Collections.Generic;

public partial class ScoutList : Page, IScoutList
{
    protected void Page_Load(object sender, EventArgs e)
    {
        new PScoutList(this);
        OnInitialLoad();
    }

    protected void Page_Init(object sender, EventArgs e)
    {
        gvScouts.RowDataBound += new GridViewRowEventHandler(gvScouts_RowDataBound);
    }

    void gvScouts_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            Scout scout = (Scout)e.Row.DataItem;
            Literal litFirstName = (Literal)e.Row.Cells[0].FindControl("litFirstName");
            Literal litLastName = (Literal)e.Row.Cells[1].FindControl("litLastName");
            litFirstName.Text = scout.FirstName;
            litLastName.Text = scout.LastName;
        }
    }

    #region IScoutList Members

    public event EventHandler InitialLoad;

    public List<Scout> Scouts
    {
        set
        {
            gvScouts.DataSource = value;
            gvScouts.DataBind();
        }
    }

    #endregion
    
    private void OnInitialLoad()
    {
        if (InitialLoad != null)
        {
            InitialLoad(this, EventArgs.Empty);
        }
    }
}
